package ${controllerPackage};

import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import java.util.*;

/**
 * 控制层：${entityName}Controller
 * 路由前缀：/api/${modulePrefix}/${lowerName}
 * 功能：分页查询、列表、创建、更新、删除、批量删除
 * 预留：权限注解占位（如 @PreAuthorize、@SaCheckPermission）
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/${modulePrefix}/" + "${lowerName}")
public class ${entityName}Controller {
  private final ${entityName}Service service;

  /**
   * 分页查询（示例：未接入分页插件，页面可直接使用 list 或接入 MyBatis-Plus 分页）
   */
  // @PreAuthorize("hasAuthority('${permissionPrefix}:page')")  // 权限占位：分页
  @GetMapping("/page")
  public Map<String,Object> page(@RequestParam int current,@RequestParam int size,@RequestParam(required=false) String keyword){
    List<${entityName}> list = service.list();
    Map<String,Object> res = new HashMap<>();
    res.put("code",200);res.put("message","success");res.put("data",list);
    return res;
  }

  /** 列表查询 */
  // @PreAuthorize("hasAuthority('${permissionPrefix}:list')")  // 权限占位：列表
  @GetMapping("/list") public List<${entityName}> list(){ return service.list(); }
  /** 新增 */
  // @PreAuthorize("hasAuthority('${permissionPrefix}:create')")  // 权限占位：新增
  @PostMapping public boolean create(@RequestBody ${entityName} e){ return service.save(e);} 
  /** 修改 */
  // @PreAuthorize("hasAuthority('${permissionPrefix}:update')")  // 权限占位：修改
  @PutMapping public boolean update(@RequestBody ${entityName} e){ return service.updateById(e);} 
  /** 删除 */
  // @PreAuthorize("hasAuthority('${permissionPrefix}:delete')")  // 权限占位：删除
  @DeleteMapping("/{id}") public boolean remove(@PathVariable Long id){ return service.removeById(id);} 
  /** 批量删除 */
  // @PreAuthorize("hasAuthority('${permissionPrefix}:batchDelete')")  // 权限占位：批量删除
  @DeleteMapping("/batch") public boolean removeBatch(@RequestBody List<Long> ids){ return service.removeByIds(ids);} 
}


